// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Icon from 'vue-svg-icon/Icon.vue'
import axios from 'axios'
import _g from './assets/js/global'
import store from './vuex/store'
//引入md5
import Crypto from 'crypto'


Vue.config.productionTip = false

Vue.use(ElementUI)
Vue.component('icon', Icon); 
window.axios = axios

axios.defaults.withCredentials = true

const bus = new Vue()
window.bus = bus
window._g = _g
window.store = store
window.Crypto = Crypto

axios.defaults.baseURL = 'http://api.fengzhan100.com'

let whiteList = ['']
router.beforeEach((to, from, next) => {
	if(to.name=="登录") {
		next()
	}else {
		axios.get('/api/backend/account/site/current').then(response => {
			if(response.data.code==200) {
				next()
			}
		}).catch(response => {
			next('login')
		})
	}
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
